package com.ljx.rabbit.service.impl;

import com.ljx.rabbit.context.BaseContext;
import com.ljx.rabbit.domain.po.User;
import com.ljx.rabbit.domain.po.UserLikes;
import com.ljx.rabbit.mapper.UserMapper;
import com.ljx.rabbit.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-01-21
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public List<UserLikes> getUserLikes() {
        List<UserLikes> likes = mongoTemplate.find(
                Query.query(Criteria.where("userId").is(BaseContext.getCurrentId())),
                UserLikes.class
        );
        return likes;
    }
}
